package com.baseframe.tool.result;


import lombok.Data;
import lombok.ToString;

@Data
@ToString
public class R<T>{

    private int code;
    private T data;
    private String message;


    public static <T> R<T> data(T data){

        R<T> R = new R<T>();
        R.setCode(200);
        R.setData(data);
        R.setMessage("操作成功");
        return R;
    }

    public static R<Object> success(String message){
        R<Object> R = new R<Object>();
        R.setCode(200);
        R.setMessage(message);
        return R;
    }

    public static R<Object> fail(String message){
        R<Object> R = new R<Object>();
        R.setCode(400);
        R.setMessage(message);
        return R;
    }

    public static R<Object> fail(int code,String message){
        R<Object> R = new R<Object>();
        R.setCode(code);
        R.setMessage(message);
        return R;
    }


    public static R<Object> success(){

        return R.success("操作成功~");
    }

    public static R<Object> fail(){

        return R.fail("操作失败~");
    }
}
